export const randomString = (len=10) => {
  return Math.random().toString(35).slice(2, len + 2);
}

export const randomListIndex = (list) => {
  return Math.floor(Math.random() * list.length);
}

export const randomSelect = (list) => {
  return list[randomListIndex(list)];
}

export const path = (entry) => {
  const paths = [];
  for (let curr = entry; curr; curr = curr.pred) {
    paths.push(curr);
  }
  return paths.reverse();
}


export const createEntry = ({propLens=5,  props={}}={}) => {
  let entry = Object.fromEntries(
    [...Array(propLens)].map(() => [randomString(5), randomString(10)])
  );

  const item = {...entry, ...props};

  Object.defineProperty(item, 'succ', {
    value:[],
    enumerable: false
  })

  return item;
}
